diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-12-18 11:56:59 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-12-18 11:56:59 +0100 |
| commit | d592085dc0fec023dd9f3437d4c756d402ed8c8f (patch) | |
| tree | 9bba6873cefac197934ca41eed22b0b7054e3f60 /src/pages/thematique/[slug].tsx | |
| parent | 67581629ea87162e6d47b39b867b37a9a50754aa (diff) | |
fix(pages): use dynamic imports for the table of contents
The ToCWidget relies on Javascript to display the headings. If JS is
disabled in the browser, the widget is empty. For a better UX, we
should use dynamic imports. Now, the ToC is only displayed when JS is
enabled.
Diffstat (limited to 'src/pages/thematique/[slug].tsx')
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 56b956f..ef21fb4 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -1,6 +1,7 @@ /* eslint-disable max-statements */ import type { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps } from 'next'; +import dynamic from 'next/dynamic'; import Head from 'next/head'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; @@ -14,7 +15,6 @@ import { PageSidebar, PageBody, LoadingPage, - TocWidget, Spinner, } from '../../components'; import { @@ -48,6 +48,13 @@ import { useThematicsList, } from '../../utils/hooks'; +const Toc = dynamic( + async () => import('../../components').then((mod) => mod.TocWidget), + { + ssr: false, + } +); + export type ThematicPageProps = { data: { currentThematic: WPThematic; @@ -152,7 +159,7 @@ const ThematicPage: NextPageWithLayout<ThematicPageProps> = ({ data }) => { }} /> <PageSidebar> - <TocWidget + <Toc heading={<Heading level={2}>{messages.widgets.tocTitle}</Heading>} tree={[ ...tree, |
